<!DOCTYPE html>

<html xmlns:th="http://www.thymeleaf.org">

<body>
<!--导航栏-->
<div th:fragment="nav">
    <nav class="navbar navbar-default">
        <div class="container-fluid">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="/">白起社区</a>
            </div>

            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <form class="navbar-form navbar-left" action="/" method="get">
                    <div class="form-group">
                        <input type="text" class="form-control" name="search" placeholder="输入搜索问题" th:value="${search}">
                    </div>
                    <button type="submit" class="btn btn-default">搜索</button>
                </form>
                <ul class="nav navbar-nav navbar-right">
                    <li th:if="${session.user!=null}" th:class="${navType=='publishNav'}?'active':''">
                        <a href="/publish">提问<span class="glyphicon glyphicon-comment" aria-hidden="true"></span></a>
                    </li>
                    <li th:if="${session.user!=null}" th:class="${navType=='notifyNav'}?'active nav-box':'nav-box'">
                        <a href="/profile/notifies">通知
                            <span class="glyphicon glyphicon-bell"></span>
                            <span class="badge" th:text="${session.unreadCount}"
                                  th:if="${session.unreadCount!=0}" style="margin-bottom: 5px;margin-left: -5px;">
                            </span>
                        </a>
                    </li>
                    <li th:if="${session.user==null}">
<!--                        <a href="https://gitee.com/oauth/authorize?client_id=da0b07bbbcbfc5eb7bdc0996f77e92af8440c44c83d09055eaac1db5ce56262a&custom=tom&redirect_uri=http://localhost:8886/callback&response_type=code&state=1">登录-->
<!--                        </a>-->
                        <button type="button" class="btn btn-success navbar-btn">
                            <a th:href="@{https://gitee.com/oauth/authorize(client_id='da0b07bbbcbfc5eb7bdc0996f77e92af8440c44c83d09055eaac1db5ce56262a',
                        redirect_uri=${#httpServletRequest.getServletContext().getAttribute('redirectUri')},response_type='code',state=1)}" style="color: blue">登录
                            </a>
                        </button>
                    </li>
                    <li class="dropdown" th:if="${session.user!=null}">
                        <a href="#" class="dropdown-toggle avatar" data-toggle="dropdown"
                           role="button" aria-haspopup="true" aria-expanded="false">
                            <img class="img-rounded" th:src="${session.user.avatarUrl}" style="width: 20px">
                            <span th:text="${session.user.getName()}">我的</span>
                            <span class="caret"></span>
                        </a>                    <ul class="dropdown-menu">
                        <li><a href="/profile/questions">我的问题</a></li>
                        <li><a href="/profile/notifies">最新回复</a></li>
                        <li><a href="/profile/likes">我的收藏</a></li>
                        <li><a href="/logout">退出登录</a></li>
                    </ul>
                    </li>
                </ul>
            </div>
        </div>
    </nav>
</div>

</body>

</html>